package main

import (
	. "GO_data_structures_and_algorithms/tool"
)

type BitMap struct {
	bits []int64
}

func (bitmap *BitMap) NewBitMap(Max int64) {

	bitmap.bits = make([]int64, (Max+64)>>6)

}

func (bitmap *BitMap) add(num int64) {
	println("开始添加")
	Print32(num & 63)
	Print32(int64(1) << (num & 63))
	Print32(bitmap.bits[num>>6])
	bitmap.bits[num>>6] |= (int64(1) << (num & 63))
	println("结束添加")

}
func (bitmap *BitMap) delete(num int64) {
	println("开始删除")
	Print32(num & 63)
	Print32(int64(1) << (num & 63))
	Print32(^(int64(1) << (num & 63)))
	Print32(bitmap.bits[num>>6])
	bitmap.bits[num>>6] &= (^(int64(1) << (num & 63)))
	println("结束删除")
}
func (bitmap *BitMap) contains(num int64) bool {
	println("开始查询")
	Print32(num & 63)
	Print32(int64(1) << (num & 63))
	Print32(bitmap.bits[num>>6])
	println("结束查询")
	return (bitmap.bits[num>>6] & (int64(1) << (num & 63))) != 0
}

func main() {

	var bits BitMap
	bits.NewBitMap(1000)
	println(bits.bits)
	bits.add(999)
	println(bits.contains(999))
	bits.delete(999)
	println(bits.contains(999))
	//var a int8 = -128
}
